package okl.lab.namesFilter.tests.cases
{
	import flash.events.EventDispatcher;
	
	import flashx.textLayout.debug.assert;
	
	import mx.collections.ArrayCollection;
	
	import okl.lab.namesFilter.controller.events.UsersEvent;
	import okl.lab.namesFilter.model.AppModel;
	import okl.lab.namesFilter.tests.utils.TestDataGenerator;
	
	import org.flexunit.async.Async;

	/**
	 * At the moment the model is very basic.
	 * So only event on users update test.
	 */
	public class AppModelTest
	{	
		private var model:AppModel;
		private var dispatcher:EventDispatcher;
		[Before]
		public function setUp():void
		{
			model=new AppModel();
			dispatcher=new EventDispatcher();
			model.eventDispatcher=dispatcher;
		}
		[Test(async)]
		public function testUsersDataUpdateEvent():void{		
			Async.handleEvent(this, model.eventDispatcher, UsersEvent.UPDATED, usersDataUpdateEventCallback);
			model.users= new ArrayCollection(TestDataGenerator.generateUsers());
		}
		
		protected function usersDataUpdateEventCallback(event:UsersEvent, obj:Object):void{
			assert();
		}
		
		[After]
		public function tearDown():void
		{
			model=null;
			dispatcher=null
		}

		
		
	}
}